/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.sales.hanserver.action.hancadso.purchaserequest.insert;

import br.com.sales.hanserver.action.hancadso.purchaserequest.GetDataRequestGridAction;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author v
 */
public class InsertNewItem extends InsertNewRequestQuery {

    public InsertNewItem() {
    }

    public Map insertRequest(Map fields) {
        try {
            insertRequest(
                    new Timestamp(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
                            .parse(fields.get("DATE").toString()).getTime()),
                    new Timestamp(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
                            .parse(fields.get("DATE").toString()).getTime()),
                    fields.get("NR_SEQ_PF") != null ? Long.parseLong(fields.get("NR_SEQ_PF").toString()) : null,
                    (List) fields.get("PRODUCTS"));
        } catch (Exception ex) {
            Logger.getLogger(InsertNewItem.class.getName()).log(Level.SEVERE, null, ex);
        }
        return new GetDataRequestGridAction().getLastRequest(0L);
    }
}
